Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the example: remove api token error when we fetch recipes #112

Merged
merged 1 commit into from
Sep 27, 2024

Conversation

caarmen
Copy link
Contributor

@caarmen caarmen commented Sep 26, 2024

Description

This fixes a minor bug where we had an error message in the recipe selection list.

Steps to reproduce:

  • open the example page
  • copy your api token
  • expected behavior: the recipes list is populated
  • actual behavior: the recipes list is populated BUT there's still an error about a missing api token

Before:
image

With the fix:
image

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

  • I've read & comply with the contributing guidelines
  • I have tested my code for new features & regressions on both mobile & desktop devices, using the latest version of major browsers.
    • Not really, it's "just" an example 🤞🏻 😅
  • I have made corresponding changes to the documentation (README.md).
    • I don't think anything is needed.
  • I've checked my modifications for any breaking changes.
    • Not really, it's "just" an example 🤞🏻 😅

@caarmen caarmen changed the title Remove the "No recipes fetched, give a valid api token" recipes select element, if we successfully retrieved the recipes. Fix the example: remove api token error when we fetch recipes Sep 26, 2024
@caarmen caarmen marked this pull request as ready for review September 26, 2024 12:31
Comment on lines 157 to 160
const selectElement = document.querySelector('#listRecipes');
// Remove our "warning" select option about an invalid/missing api token.
selectElement.remove(0);
const placeholderOption = document.createElement('option');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well play, but the bug is worth that what you detect. Every time the input apitoken loose focus, the recipes list is added to the previous.

This will fix all issues

const selectElement = document.querySelector('#listRecipes');
     // Flush select before adding new options
      selectElement.innerHTML = '';
 const placeholderOption = document.createElement('option');

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well play, but the bug is worth that what you detect. Every time the input apitoken loose focus, the recipes list is added to the previous.

Ah, nice catch! 😅

I've adjusted the fix with your suggestion. Thanks!

@caarmen caarmen force-pushed the dev/fix-invalid-token-recipe-selection branch from 4ee98c0 to 3c696e1 Compare September 26, 2024 14:11
@caarmen caarmen requested a review from jparez September 26, 2024 15:44
Copy link
Contributor

@jparez jparez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank for this PR !

@caarmen caarmen merged commit 53d2c39 into main Sep 27, 2024
1 check passed
@caarmen caarmen deleted the dev/fix-invalid-token-recipe-selection branch September 27, 2024 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants